export default function getLocation() {
    wx.getLocation({    //获取位置信息
        type: 'wgs84',
        success(res) {
            console.log(res);
            const latitude = res.latitude
            const longitude = res.longitude
            const speed = res.speed
            const accuracy = res.accuracy

            // app.globalData.latitude=latitude
            // app.globalData.longitude=longitude
            // console.log(app);

            wx.setStorageSync('latitude', latitude)
            // wx.setStorage({
            //     key:"latitude",
            //     data:latitude,
            //     success(){

            //     }
            // })
        },
        fail(err) {
            let _this = this;
            wx.getSetting({     //获取权限状态
                success(e) {
                    console.log(e);
                    if (typeof (e.authSetting['scope.userLocation']) != 'undefined' && !e.authSetting['scope.userLocation']) {
                        wx.showModal({
                            title: '提示',
                            content: '您将打开设置提供定位权限',
                            complete: (res) => {
                                if (res.confirm) {
                                    wx.openSetting({
                                        success(e) {
                                            console.log(e);
                                            if (e.authSetting['scope.userLocation']) {
                                                wx.getLocation({
                                                    type: 'wgs84',
                                                    success(res) {
                                                        console.log(res);
                                                        const latitude = res.latitude
                                                        const longitude = res.longitude
                                                        const speed = res.speed
                                                        const accuracy = res.accuracy
                                                    }
                                                })
                                            }
                                        },
                                    })
                                }
                            }
                        })

                    }
                }
            })
        }
    })
}